package demo2;

import java.util.Objects;

public class Animal implements Comparable<Animal> {
    public String name;
    public String age;

    public int password = 123456;

    public Animal(String name, String age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Animal animal = (Animal) o;
        return Objects.equals(name, animal.name) && Objects.equals(age, animal.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public int compareTo(Animal o) {
        return this.password - o.password;
    }

    class cat {
        private String age;
        public void print() {
            Animal.this.age = "10";
        }
    }
}